//
//  JHRecommendTableViewCell.m
//  Liberty Voice
//
//  Created by dlios on 15-5-13.
//  Copyright (c) 2015年 ClearLove. All rights reserved.
//

#import "JHRecommendTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface JHRecommendTableViewCell ()
@property(nonatomic,retain)UIImageView *recomImage;
@property(nonatomic,retain)UIImageView *Image1;
@property(nonatomic,retain)UILabel *recomLabel;
@property(nonatomic,retain)UILabel *recomLabel2;
@end

@implementation JHRecommendTableViewCell
- (void)dealloc
{
    [_recomImage release];
    [_recomLabel release];
    [_recomLabel2 release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        //  头像
        self.recomImage = [[[UIImageView alloc] init]autorelease];
        _recomImage.image = [UIImage imageNamed:@"iconfont-play"];
        _recomImage.layer.cornerRadius = 24.5;
        _recomImage.layer.masksToBounds = YES;
//        _recomImage.backgroundColor = [UIColor blueColor];
        [self.contentView addSubview:_recomImage];
        //  标题
        self.recomLabel = [[[UILabel alloc] init] autorelease];
//        _recomLabel.backgroundColor = [UIColor yellowColor];
        _recomLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:_recomLabel];
        //  播放图片
        self.Image1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iconfont-play"]];
        [self.contentView addSubview:_Image1];
        //  播放次数
        self.recomLabel2 = [[[UILabel alloc] init] autorelease];
        _recomLabel2.font = [UIFont systemFontOfSize:10];
//        _recomLabel2.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_recomLabel2];
    }return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    _recomImage.frame = CGRectMake(15, 5, 50, 50);
    _recomLabel.frame = CGRectMake(75, 5, 200, 20);
    _Image1.frame = CGRectMake(75, 25, 10, 10);
    _recomLabel2.frame = CGRectMake(87, 25, 100, 10);
}
- (void)setRecom:(JHREcommend *)recom
{
    if (recom != _recom) {
        [_recom release];
        _recom = [recom retain];
    }
    _recomLabel.text = recom.title;
    [_recomImage  sd_setImageWithURL:[NSURL URLWithString:recom.coverSmall]];
    NSString *num = @"";
    if (recom.playsCounts < 10000) {
      num = [NSString stringWithFormat:@"%ld",recom.playsCounts];
    }else
        if (recom.playsCounts > 10000) {
//            NSInteger a = (recom.playsCounts / 10000.00);
            num = [NSString stringWithFormat:@"%.1f万",recom.playsCounts / 10000.0];
        }
    _recomLabel2.text = num;
}
- (void)awakeFromNib {
    // Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
